package com.xjc.business.controller.stu;

import com.xjc.business.entity.po.stu.CirclePublishPo;
import com.xjc.business.entity.vo.stu.CircleFriendsVo;
import com.xjc.business.service.StudentCircleFriendsService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 徐锦程
 * 时间:2025-02-19 10:09
 */

@RestController
@RequestMapping("/student/circle")
public class StuCircleController {

    @Autowired
    StudentCircleFriendsService studentCircleFriendsService;

    /**
     * 发布朋友圈
     * @param circlePublishPo 信息
     * @return 反馈
     */
    @PostMapping("/publish")
    public Result<String> publishCircle(@RequestBody( required = false)CirclePublishPo circlePublishPo){
        if (circlePublishPo == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return studentCircleFriendsService.publishCircle(circlePublishPo);
    }

    /**
     * 获取朋友圈
     * @param wxId 微信用户id
     * @return 朋友圈列表
     */
    @GetMapping("/getCircleList/{wxId}")
    public Result<List<CircleFriendsVo>> getCircleList(@PathVariable(value = "wxId",required = false) Integer wxId){
        if (wxId == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }
        return studentCircleFriendsService.getCircleList(wxId);
    }
}
